import Dialog from './Dialog.vue';
import {createApp, h} from 'vue';

export const openDialog = (options) => {
  const {title, content, ok, cancel,closeOnclickOverlay} = options;
  const div = document.createElement('div');
  document.body.appendChild(div);
  const app = createApp({
    render() {
      return h(Dialog, {
        visible: true, 'onUpdate:visible': (newVisible) => {
          if (newVisible === false) {
            app.unmount(div); //将Dialog挂载到div上
            div.remove();
          }
        },
        ok, cancel,closeOnclickOverlay
      }, {title, content});
    }
  });
  app.mount(div);
};
